/**
 * 账户设置。
 * @author 黄广星
 */

package com.taxsystem.huangguangxing.login;

import com.main.taxsystem.R;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class UserSettingActivity extends Activity {

	private Button alterUser,alterPassword,quitUser;
	private TextView userName;

	private SharedPreferences spLogin;
	
	protected void onCreate(Bundle savedInstanceState) {
		
		ActionBar bar = getActionBar();
        bar.setHomeButtonEnabled(true);
        bar.setIcon(R.drawable.actionbar_icon);
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setBackgroundDrawable(new ColorDrawable(0xff34a4f7));

		super.onCreate(savedInstanceState);
		setContentView(R.layout.user_setting_layout);
		// 获得实例对象
		spLogin = this.getSharedPreferences("userInfo", Context.MODE_PRIVATE);
				
		alterUser = (Button) findViewById(R.id.alter_user);
		alterPassword = (Button) findViewById(R.id.alter_password);
		quitUser=(Button)findViewById(R.id.quit_user);
		userName=(TextView)findViewById(R.id.login_user);

		if(LoginMassege.getUser().getUserName()!=null)
		{
			userName.setText(LoginMassege.getUser().getUserName());
		}
		alterUser.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {

				Intent intentAlterUser=new Intent();
				intentAlterUser.setClass(UserSettingActivity.this,AlterUserActivity.class);
				startActivity(intentAlterUser);
			}
		});
		
		alterPassword.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {

				Intent intentAlterPassword=new Intent();
				intentAlterPassword.setClass(UserSettingActivity.this,AlterPasswordActivity.class);
				startActivity(intentAlterPassword);
			}
		});
		
		quitUser.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {

				spLogin.edit().clear().commit();
				LoginMassege.setLogin(false);
				Intent intentQuit=new Intent();
				intentQuit.setClass(UserSettingActivity.this,LoginActivity.class);
				startActivity(intentQuit);
				finish();
			}
		});

	}
}
